package com.johnny.action;

import java.net.Socket;

import com.johnny.data.DataPool;
import com.johnny.data.PlayerInfo;
import com.johnny.data.RoomInfo;
import com.johnny.data.TableInfo;
import com.johnny.startup.Casino28App;

import net.sf.json.JSONObject;

public class LogoutAction implements Action {

	@Override
	public String doAction(JSONObject object, Socket socket) {
		PlayerInfo playerInfo = Casino28App.connector.getPlayerInfoBySocket(socket);
		for (RoomInfo roomInfo : DataPool.getInstance().getRoomInfos()) {
			for (TableInfo tableInfo : roomInfo.getTables()) {
				if (tableInfo.getBankerCandidateList().contains(playerInfo.getName())) {
					tableInfo.getBankerCandidateList().remove(playerInfo.getName());
					break;
				}
			}
		}
		return null;
	}

}
